home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / StreetsAlleys.dxr / Internal_1_tableau cards.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  3.4 KB  |  118 lines

  1. property spriteNum, row, maxcount, myLoc
  2. global stock, tableau, foundation, mover, equal, currentsel, godlist, points, receiver, action
  3.  
  4. on beginSprite me
  5.   myLoc = sprite(spriteNum).loc
  6.   sprite(spriteNum).visible = 1
  7.   row = determinerow(spriteNum)
  8.   receiver = 0
  9.   if objectp(tableau[row]) = 0 then
  10.     tableau.addProp(row, new(script("card pile")))
  11.   end if
  12.   if (row = #one) or (row = #two) or (row = #three) or (row = #four) then
  13.     maxcount = 7
  14.   else
  15.     maxcount = 6
  16.   end if
  17.   if tableau[row].getcardcount() < maxcount then
  18.     sprite(spriteNum).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
  19.     stock.cards.deleteAt(1)
  20.     tableau[row].addCard(spriteNum)
  21.   else
  22.     sprite(spriteNum).visible = 0
  23.   end if
  24. end
  25.  
  26. on determinerow cardnumber
  27.   if (cardnumber >= 14) and (cardnumber <= 27) then
  28.     return #one
  29.   else
  30.     if (cardnumber >= 28) and (cardnumber <= 42) then
  31.       return #two
  32.     else
  33.       if (cardnumber >= 43) and (cardnumber <= 56) then
  34.         return #three
  35.       else
  36.         if (cardnumber >= 57) and (cardnumber <= 70) then
  37.           return #four
  38.         else
  39.           if (cardnumber >= 71) and (cardnumber <= 84) then
  40.             return #five
  41.           else
  42.             if (cardnumber >= 85) and (cardnumber <= 99) then
  43.               return #six
  44.             else
  45.               if (cardnumber >= 100) and (cardnumber <= 113) then
  46.                 return #seven
  47.               else
  48.                 if (cardnumber >= 114) and (cardnumber <= 127) then
  49.                   return #eight
  50.                 end if
  51.               end if
  52.             end if
  53.           end if
  54.         end if
  55.       end if
  56.     end if
  57.   end if
  58. end
  59.  
  60. on mouseDown me
  61.   if (sprite(spriteNum).member <> member("empty", "playing cards")) and (tableau[row].getlastcard().spnum = spriteNum) then
  62.     puppetSound(3, "pickcard")
  63.     action = 1
  64.     sprite(spriteNum).locZ = spriteNum + 2000
  65.     mover = timeout("move").new(1, #moveme, me)
  66.   end if
  67. end
  68.  
  69. on moveme me
  70.   sprite(spriteNum).loc = the mouseLoc
  71.   if the stillDown = 0 then
  72.     mover.forget()
  73.     sprite(spriteNum).loc = myLoc
  74.   end if
  75. end
  76.  
  77. on mouseUp me
  78.   sprite(spriteNum).locZ = spriteNum
  79.   if sprite(spriteNum).member <> member("empty", "playing cards") then
  80.     if sprite(spriteNum).loc = the mouseLoc then
  81.       if equal = 1 then
  82.         puppetSound(3, "pickcard")
  83.         action = 0
  84.         mover.forget()
  85.         sprite(spriteNum).locZ = spriteNum
  86.         sprite(spriteNum).loc = tableau[row].getlastcard().location
  87.         sprite(spriteNum).locZ = spriteNum
  88.         sprite(spriteNum).loc = tableau[row].getlastcard().location
  89.         sprite(currentsel).member = sprite(spriteNum).member
  90.         if tableau[row].getcardcount() > 1 then
  91.           sprite(spriteNum).visible = 0
  92.         else
  93.           sprite(spriteNum).member = member("empty", "playing cards")
  94.         end if
  95.         if sprite(currentsel).visible = 0 then
  96.           sprite(currentsel).visible = 1
  97.         end if
  98.         tableau[row].cards.deleteOne(tableau[row].getlastcard())
  99.         godlist.addCard(currentsel)
  100.         if (currentsel >= 10) and (currentsel <= 13) then
  101.           points = points + 10
  102.         end if
  103.         equal = 0
  104.         currentsel = 0
  105.         godlist = VOID
  106.         checkwin()
  107.       else
  108.         if equal = 0 then
  109.           puppetSound(3, "dropcard")
  110.           mover.forget()
  111.           sprite(spriteNum).locZ = spriteNum
  112.           sprite(spriteNum).loc = tableau[row].getlastcard().location
  113.         end if
  114.       end if
  115.     end if
  116.   end if
  117. end
  118.